package cn.ronghui.project.domain.student.service.impl;

import cn.ronghui.project.domain.student.adapter.repository.IStudentRepository;
import cn.ronghui.project.domain.student.model.entity.StudentEntity;
import cn.ronghui.project.domain.student.service.IStudentService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class StudentService implements IStudentService {

    private final IStudentRepository repository;

    public StudentService(IStudentRepository repository) {
        this.repository = repository;
    }

    @Override
    public StudentEntity queryStudentInfo(String studentId) {
        if(StringUtils.isBlank(studentId)){
            log.warn("查询学生信息失败，studentId为空");
            return null;
        }
        log.info("查询学生信息，studentId:{}", studentId);
        return repository.queryStudentInfo(studentId);
    }

    @Override
    public void updateStudentInfo(StudentEntity studentEntity) {
        log.info("更新学生信息，studentEntity:{}", studentEntity);
        repository.updateStudentInfo(studentEntity);
    }
}
